﻿/*
 * Created by SharpDevelop.
 * User: Michael
 * Date: 3/02/2014
 * Time: 5:47 PM
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */
using System;
using System.Windows;
using System.Runtime.Remoting;
using AdvGenContact.App;
using AdvGenContatct.Views;


namespace AdvGenContact.WPF
{
	/// <summary>
	/// Description of BaseWindow.
	/// </summary>
	public class BaseWindow : Window, IBaseView
	{
		public IApp Controller {get;set;}
	
		public BaseWindow() :base()
		{
			string className = this.GetType().Name;
			string controllerName = className.Replace("Window","App");
			string assblemlyName = System.Reflection.Assembly.GetEntryAssembly().GetName().Name;
			if (assblemlyName == null)
				return;
			string appName = assblemlyName.Substring(0,assblemlyName.IndexOf("."))+".App.WPF";
			ObjectHandle obj = Activator.CreateInstance( appName,appName+"."+controllerName);
			Controller = (IApp) obj.Unwrap();
			Controller.View = this;
			
		}
	}
}
